<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateAgentWithdrawByYmsh extends Migrator
{
    public function up()
    {
        $sql = <<<SQL
CREATE TABLE `agent_merchant_stat` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `settle_at` date NOT NULL COMMENT '结算时间',
  `created_at` timestamp  COMMENT '创建时间',
  `updated_at` timestamp  ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `success_at` timestamp   COMMENT '成功时间',
  `submit_at` timestamp   COMMENT '提交时间',
  `amount` varchar(30)  DEFAULT NULL COMMENT '结算金额',
  `merchant_id` int(11) DEFAULT NULL COMMENT '有美生活商户id',
  `status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0:等待提现,1:待核算,2:待打款,3:已打款',
  PRIMARY KEY (`id`)
)  COMMENT='有美生活统计日期';

SQL;

        $this->execute($sql);

        $sql = <<<SQL
CREATE TABLE `agent_merchant_stat_item` (
  `agent_merchant_stat_id` int(11) NOT NULL,
  `settle_at` varchar(255) DEFAULT NULL,
  `agent_id` int(11) DEFAULT NULL COMMENT '代理',
  `merchant_id` int(11) DEFAULT NULL COMMENT '有美生活商户',
  `app_id` int(11) DEFAULT NULL COMMENT '有美生活应用',
  `amount` int(15) DEFAULT NULL
)  COMMENT='有美生活统计日期明细';
SQL;

        $this->execute($sql);

    }

    public function down()
    {
        $this->table('agent_merchant_stat')->drop();
        $this->table('agent_merchant_stat_item')->drop();
    }
}
